<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>序列化</title>
</head>
<body>
    <script>
         var obj ={
            name:'tom',
            age:13,
            'say address':'广西'
        }
        console.log(localStorage)
        // localStorage.setItem()存储键值对,到浏览器的本地存储.
        // JSON序列化：将对象转换成字符串
        localStorage.setItem('local',JSON.stringify(obj));
        // localStorage.getItem()向浏览器获取某个键值对
        // localStorage.removeItem(key)删除某个键值对
        // localStorage.clear() 清空所有键值对
        var res = localStorage.getItem('local');
        // JSON反序列化：将字符串转换成对象
        console.log(JSON.parse(res));
    </script>
</body>
</html>